﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//[RequireComponent(typeof(CircleCollider2D))]
public class Interaction : MonoBehaviour
{
    //   SpriteRenderer highlightSprite;
    //   SpriteRenderer keySprite;
    List<SpriteRenderer> sprites;
    Color color;
    public virtual void Start()
    {

    }
    public virtual void Awake()
    {
        //   highlightSprite = this.gameObject.GetComponent<SpriteRenderer>();
        //   highlightSprite.sprite = this.GetComponentInParent<SpriteRenderer>().sprite;
        //   highlightSprite.color = Color.black;
        //   highlightSprite.enabled = false;

        //   keySprite = this.transform.Find("Key").GetComponent<SpriteRenderer>();
        //  keySprite.enabled = false;


        //  this.transform.localScale = new Vector3(1.1f, 1.1f, 1);
        sprites =new List<SpriteRenderer>(this.GetComponentsInChildren<SpriteRenderer>());
        color = sprites[0].color;
    }
    bool isSelected = false;
    public virtual void OnSelected()
    {
        //   highlightSprite.enabled = true;
        //  keySprite.enabled = true;
        foreach(var x in sprites)
        {
            x.color = Color.gray;
        }
        isSelected = true;
    }
    public virtual void Invoke(CombinableItemField info)
    {
        AudioControl.Instance.PlaySound("扫描拾取");
    }
    public virtual void InvokePreference(object info)
    {

    }
    public virtual void FixedUpdate()
    {
        if (isSelected == false)
        {
            //      highlightSprite.enabled = false;
            //     keySprite.enabled = false;
            foreach (var x in sprites)
            {
                x.color = color;
            }
        }
        isSelected = false;
    }

}
